package com.zjr.action;

import java.util.*;

import com.opensymphony.xwork2.ModelDriven;
import com.zjr.domain.Department;
import com.zjr.service.DepartmentService;
/**
 * 部门action类
 * */
public class DepartmentAction extends SuperAction implements ModelDriven<Department>{
	private static final long serialVersionUID = 1L;
	
	private Department department = new Department();
	@Override
	public Department getModel() {
		return department;
	}
	
	private DepartmentService departmentService;
	public void setDepartmentService(DepartmentService departmentService) {
		this.departmentService = departmentService;
	}
	
	//查询所有部门
	public String findAll(){
		List<Department> list = departmentService.findAll();
		request.setAttribute("departments", list);
		return "list";
	}
	
	//添加部门
	public String save(){
		departmentService.save(department);
		return "add_success";
	}
}
